﻿using System;
using System.IO;
using WpfAi.Core;
using WpfAi.Enum;
using System.Windows.Forms;

namespace WpfAi
{
    public class GlobalEnvironment
    {
        /// <summary>
        /// 串口
        /// </summary>
        public static string Com { get; set; }
        /// <summary>
        /// 波特率
        /// </summary>
        public static int Rate { get; set; }
        /// <summary>
        /// 串口操作对象
        /// </summary>
        public static SerialClass Serial { get; set; }
        /// <summary>
        /// 没有图片时显示的默认图片
        /// </summary>
        public static string NoPicPath { get; } = @"../Resources/noPic.png";
        /// <summary>
        /// 获取存储路径
        /// </summary>
        /// <returns></returns>
        public static string PhotoUrl
        {
            get
            {
                return PhotoStorageUrl;
            }
        }
        /// <summary>
        /// 本地存储路径
        /// </summary>
        public static string PhotoStorageUrl
        {
            get
            {
                string photoStorageUrl = "C:\\ImageSavePath\\";
                try
                {
                    if (!Directory.Exists(photoStorageUrl))
                    {
                        Directory.CreateDirectory(photoStorageUrl);
                    }
                }
                catch (Exception)
                {
                    return string.Empty;
                }
                return photoStorageUrl;
            }
        }
        /// <summary>
        /// 当前测试的PCB单板SN
        /// </summary>
        public static string PCBQRCode { get; set; }
        /// <summary>
        /// 当前测试的外壳SN
        /// </summary>
        public static string ScreenQRCode { get; set; }

        public static EnumWindowType WindowType { get; set; }

        public static EnumBoardType BoardType { get; set; }

        public static string GetStationID()
        {
            if (WindowType == EnumWindowType.Core && BoardType == EnumBoardType.Board)
            {
                return "ET5E057";
            }
            else if (WindowType == EnumWindowType.Core && BoardType == EnumBoardType.Integrate)
            {
                return "ET5E058";
            }
            else if (WindowType == EnumWindowType.Screen && BoardType == EnumBoardType.Board)
            {
                return "ET5E059";
            }
            else if (WindowType == EnumWindowType.Screen && BoardType == EnumBoardType.Integrate)
            {
                return "ET5E061";
            }
            else 
                return "ET5E060";
        }

        public static string GetStationName()
        {
            if (WindowType == EnumWindowType.Core && BoardType == EnumBoardType.Board)
            {
                return "AI核心板单板测试";
            }
            else if (WindowType == EnumWindowType.Core && BoardType == EnumBoardType.Integrate)
            {
                return "AI核心板整机测试";
            }
            else if (WindowType == EnumWindowType.Screen && BoardType == EnumBoardType.Board)
            {
                return "AI屏幕单体测试";
            }
            else if (WindowType == EnumWindowType.Screen && BoardType == EnumBoardType.Integrate)
            {
                return "AI屏幕整机测试";
            }
            else
                return "AI屏幕校验测试";
        }

        public static string GetPCName()
        {
            return SystemInformation.ComputerName;
        }

    }
}